package com.zhdl.modules.autopick.entity;

import lombok.Data;

import java.util.List;

@Data
public class CoordinateSensor {
    /**
     * 坐标点Id
     */
    public int id;

    /**
     * 坐标点名称
     */
    public String name;

    /**
     * 坐标实际距离
     */
    public int distance;

    /**
     * 传感器类型
     * 0 液压剂报警 1 备战席报警 2 电机到位报警
     */
    public List<SlagSensor> slagSensors;

    public CoordinateSensor() {

    }

    public CoordinateSensor(int id, String name, int distance, List<SlagSensor> slagSensors) {
        this.id = id;
        this.name = name;
        this.distance = distance;
        this.slagSensors = slagSensors;
    }

    /**
     * 根据传感器类型 判断篮子id
     *
     * @param type 传感器类型
     * @return 传感器id
     */
    public int getSensorByType(String type) {
        for (SlagSensor sensor : slagSensors) {
            if (sensor.getType().equals(type)) {
                return sensor.getId();
            }
        }
        return -1;
    }

}
